/**
 * Kernel Monkeys
 * Andrew Boguk
 * Sergiy Kulyk
 * Nicholas Swartzendruber
 */

/*
 * sched.h
 *
 * @Author: Andrew Boguk
 */

#ifndef SCHED_H_
#define SCHED_H_

#include "queue.h"
//#include "cpu.h"

#define MAX_ELEMENTS 100

#define INT_TIMER 0
#define INT_IO 1
#define INT_IO_REQUEST 2

#define STATE_RUNNING 0
#define STATE_READY 1
#define STATE_INTERRUPTED 2
#define STATE_BLOCKED 3

#define SEM_UNLOCKED -1

#define BLOCKED_NONE 0
#define BLOCKED_IO 1
#define BLOCKED_SEM 2

//Forward declaration since circular inclusion with cpu.h
struct pcb_t;
typedef struct pcb_t* PCBRecord_;

typedef struct Sched_Struct* Scheduler;

Scheduler sched_create(Queue ready_queue);
void sched_switch(Scheduler sched, int type);
PCBRecord_ sched_getRunning(Scheduler sched);
void sched_printBlocked(Scheduler sched);
void sched_getLock(Scheduler sched);
void sched_releaseLock(Scheduler sched);

struct Sched_Struct
{
	Queue ready;
	Queue blocked;    //IO block queue
	Queue locked;     //Semaphore block queue
	int semaphore;
	PCBRecord_ running;
};

#endif /* SCHED_H_ */
